voicemeeter\interface\parameters/
eq.rs1use super::*;
3
4enum Mode {
5 Strip,
6 Bus,
7}
8
9impl std::fmt::Display for Mode {
10 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11 match self {
12 Mode::Strip => f.write_str(STRIP),
13 Mode::Bus => f.write_str(BUS),
14 }
15 }
16}
17
18pub struct EqChannelParameter<'a> {
20 remote: &'a VoicemeeterRemote,
21 mode: Mode,
22 index: ZIndex,
23 channel: usize,
24}
25
26impl<'a> EqChannelParameter<'a> {
27 pub(crate) fn new_bus(remote: &'a VoicemeeterRemote, index: ZIndex, channel: usize) -> Self {
28 Self {
29 remote,
30 mode: Mode::Bus,
31 index,
32 channel,
33 }
34 }
35
36 pub(crate) fn new_strip(remote: &'a VoicemeeterRemote, index: ZIndex, channel: usize) -> Self {
37 Self {
38 remote,
39 mode: Mode::Strip,
40 index,
41 channel,
42 }
43 }
44 pub(crate) fn name(&self) -> impl std::fmt::Display + '_ {
45 struct N<'s>(&'s Mode, &'s ZIndex, &'s usize);
46 impl std::fmt::Display for N<'_> {
47 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
48 write!(f, "{}[{}].EQ.channel[{}]", self.0, self.1, self.2)
49 }
50 }
51 N(&self.mode, &self.index, &self.channel)
52 }
53 pub fn param(&self, cell: usize, dot: impl ToString) -> Cow<'static, ParameterNameRef> {
55 Cow::Owned(format!("{}.cell[{}].{}", self.name(), cell, dot.to_string()).into())
56 }
57 pub fn on(&self, cell: usize) -> BoolParameter<'_> {
59 BoolParameter::new(self.param(cell, "on"), self.remote)
60 }
61 pub fn type_(&self, cell: usize) -> IntParameter<'_> {
63 IntParameter::new(self.param(cell, "type"), self.remote, 0..=6)
65 }
66 pub fn f(&self, cell: usize) -> FloatParameter<'_> {
68 FloatParameter::new(self.param(cell, "f"), self.remote, 20.0..=20_000.0)
70 }
71 pub fn gain(&self, cell: usize) -> FloatParameter<'_> {
73 FloatParameter::new(self.param(cell, "gain"), self.remote, -36.0..=18.0)
76 }
77 pub fn q(&self, cell: usize) -> IntParameter<'_> {
79 IntParameter::new(self.param(cell, "q"), self.remote, 1..=100)
81 }
82}